<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>toAudio</title>
  <link rel="stylesheet" href="../stylesheets/common.css" />
  <link rel="stylesheet" href="../stylesheets/index.css" />
  <style>
    #num:invalid {
      border: red 1px solid;
    }
    .allCenter {
      position: absolute;
      width: 700px;
      height: 30px;
      text-align: center;
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      right: 0;
      margin: auto;
    }
  </style>
</head>
<body>
  <div class="allCenter">
    <input type="number" class="form-control" id="num"> 
    <span id="speak" class="btn btn-primary">点击播放数字</span>
  </div>

  <script src="../javascripts/numToAudio.js"></script>
  <script>
    document.getElementById("speak").onclick = function () {
      var number = Number(document.getElementById("num").value);
      console.log(number);
      if (typeof number !== 'number') {
        alert("输入不是数字");
        return;
      }
      numAudio(number);
    }
  </script>
</body>
</html>